<%--
  Created by IntelliJ IDEA.
  User: 19416
  Date: 2022-10-05
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script src="JS/jquery-2.1.1.min.js">

    </script>
</head>
<body>
<%--<a href="${pageContext.request.contextPath}/FruitSysListServlet">水果信息</a>--%>

<h1 align="center">新能源动力电池信息</h1>

<table align="center" border="1px">
    <tr>
        <td>信息编号</td>
        <td>车辆类型</td>
        <td>所属城市</td>
        <td>使用单位</td>
        <td>压差报警值</td>
        <td>报警时间</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${list}" var="battery">
        <tr>
            <td><a href="<%=request.getContextPath()%>/PowerBatteryByidServlet?id=${battery.id}">${battery.id}</a></td>
            <td>${battery.carName}</td>
            <td>${battery.cityName}</td>
            <td>${battery.userName}</td>
            <td>${battery.pressureValue}</td>
            <td>${battery.time}</td>
            <td><a href="#" onclick="Delete(${battery.id})">删除</a></td>
        </tr>
    </c:forEach>

</table>
<script>
    function Delete(id) {
        if (confirm("确定要删除吗？")) {
            $.get("PowerBatteryDeleteServlet", {"id": id}, function (data) {
                if (data) {
                    alert("删除成功")
                    location.reload();
                }
            });
        }
    }
</script>
</body>
</html>
